package com.manger;

import com.manger.utils.DriverUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.File;
import java.io.FileInputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName Test
 * @Description TODO
 * @Author @LiuHongJun
 * @Date 2025/9/8 10:10
 * @Version 1.0
 */
public class Test {

    public static void main(String[] args) throws Exception{
       /* String driverPath = System.getProperty("user.dir") + "/../chromedriver-win64/chromedriver.exe";
        System.out.println(driverPath);
        System.setProperty("webdriver.chrome.driver", driverPath);
        File file = new File(driverPath);
        System.out.println(file.getCanonicalPath());
        ChromeOptions options = new ChromeOptions();
        // 禁止显示"Chrome 正受到自动测试软件的控制。"
        options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
        WebDriver driver = new org.openqa.selenium.chrome.ChromeDriver(options);
        driver.get("https://zxfw.court.gov.cn/zxfw/index.html#/pagesWsla/common/wsla/index?step=3&layyid=199405443a0b41e482ecc64e831cdab7&ajlx=1501_000001-0301&fyid=3759&ajcx=sp&layyParam=%7B%22id%22%3A%22199405443a0b41e482ecc64e831cdab7%22,%22ajlx%22%3A%221501_000001-0301%22,%22fyid%22%3A%223759%22,%22ajcx%22%3A%22sp%22,%22lafs%22%3A2,%22sfid%22%3A%22620000%22%7D&ajlxMc=%E6%B0%91%E4%BA%8B%E4%B8%80%E5%AE%A1%E6%A1%88%E4%BB%B6");
        Thread.sleep(35000);
        System.out.println("开始批量上传!");
        *//*loginContent.sendKeys("15285761207");
        password.sendKeys("lyq15285761207");*//*
        *//*while (true){
            try {
                WebElement fileInput = driver.findElement(By.xpath("/html/body/input"));
                fileInput.sendKeys("C:\\Users\\liuhj\\Desktop\\2025-09-11_190304.png");
            }catch (Exception e){
                System.out.println("没有找到input!");
            }
            Thread.sleep(2000);
        }*//*
        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(50));
        WebElement result = wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("input")));
        Thread.sleep(50000);
        result.sendKeys("C:\\Users\\liuhj\\Desktop\\2025-09-11_190304.png");*/
       /* String filePath = "C:\\Users\\liuhj\\Desktop\\9月委案传统诉状";
        File file = new File(filePath);
        File[] files = file.listFiles();
        int i = 0;
        for(File e: files){
            i++;
            String fileName = e.getName();
            fileName = fileName.substring(0, fileName.lastIndexOf("."));
            String target = "C:\\Users\\liuhj\\Desktop\\9月委案传统诉状0905\\" +fileName.replaceAll("__","_-") + "_" + i + ".pdf" ;
            Files.copy(Paths.get(e.getCanonicalPath()),Paths.get(target));
        }*/
    }
}
